{extend name="public/base" /} {block name="css"}
<link rel="stylesheet" href="__INDEX__/css/clothes-create.css"> 
<link href="__PLUGIN__/Fileinput/css/fileinput.css" rel="stylesheet">
{/block}
{block name="container"}

<div class="panel-body panel-body-nopadding" style="padding-bottom:50px;">
    <div class="inforMain">添加新面料</div>

    <form class="form-horizontal form-bordered" id="submitForm" action="" method="post" > 
        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
            <label class="col-sm-1 control-label"><span>*</span>面料编号：</label>
            <div class="col-sm-2"><input type="text" value="{$data.ml_num ?? ''}"  class="shangpingName" name="ml_num" id="" required></div>

            <label class="col-sm-1 control-label"><span>*</span>品&emsp;&emsp;类：</label>
            <div class="col-sm-2"><select name="category" id="">
                <option value="-1">请选择品类</option>
                {volist name="category" id="vo"}
                  <option value="{$vo.id}">{$vo.value}</option>
                {/volist}
            </select></div>

        </div>

        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
            <label class="col-sm-1 control-label"><span>*</span>面料属性：</label>
            <div class="col-sm-2" >
                <input type="text" value="{$data.shuxing ?? ''}" id="shuixng"  name="shuxing" required>
            </div>
            
			<label class="col-sm-1 control-label"><span>*</span>面料类别：</label>
            <div class="col-sm-2">
                <span class="sexBox">国产</span><input type="radio" value="1" name="leibie" style="width: 10%;text-align: center;line-height: 30px;float: left" >
                <span class="sexBox" style="padding-left: 15px !important;">进口</span><input type="radio" value="0" name="leibie" style="width: 10%;margin-left: 5px;text-align: center;line-height: 30px;float: left;"> 
            </div>
            
        </div>

        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
			<label class="col-sm-1 control-label"><span>*</span>成&emsp;&emsp;分：</label>
            <div class="col-sm-2" >
                <input type="text" value="{$data.chengfen ?? ''}" name="chengfen">
            </div>
			
            <label class="col-sm-1 control-label"><span>*</span>花&emsp;&emsp;色：</label>
            <div class="col-sm-2" >
               <input type="text" value="{$data.huase ?? ''}" name="huase">
            </div>

            
            
        </div>

        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
			<label class="col-sm-1 control-label"><span>*</span>颜&emsp;&emsp;色：</label>
            <div class="col-sm-2" >
                <select name="color" id="">
                     <option value="-1">请选择颜色</option>
                     {volist name="color" id="vo"}
                     <option value="{$vo.id}">{$vo.value}</option>
                     {/volist}
                </select>
            </div>
            <label class="col-sm-1 control-label"><span>*</span>纱&emsp;&emsp;织：</label>
            <div class="col-sm-2">
                <input type="text" value="{$data.shazhi ?? ''}" name="shazhi">
            </div>
            
            

        </div>

        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
			<label class="col-sm-1 control-label"><span>*</span>价&emsp;&emsp;格：</label>
            <div class="col-sm-2">
                <input type="text" value="{$data.price ?? ''}" name="price"> 
            </div>
            <label class="col-sm-1 control-label"><span>*</span>库&emsp;&emsp;存：</label>
            <div class="col-sm-2">
                <input type="text" value="{$data.kucun ?? ''}" name="kucun" {if condition="$Request.action eq 'fabricupdate'"} readonly{/if}>
            </div>
            
            
        </div>
		
		<div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
            
            
            <label class="col-sm-1 control-label"><span>*</span>是否启用：</label>
            <div class="col-sm-2">
                <span class="sexBox">是：</span><input type="radio" value="1" name="status" style="width: 10%;text-align: center;line-height: 30px;float: left" >
                <span class="sexBox" style="padding-left: 15px !important;">否：</span><input type="radio" value="0" name="status" style="width: 10%;margin-left: 5px;text-align: center;line-height: 30px;float: left;"> 
            </div>
        </div>

        <div class="form-group" style="padding-left: 2%">
            <div class="col-sm-2"></div>
            <label class="col-sm-1 control-label"><span>*</span>面料图片：</label>
            <div class="col-sm-5">
                <input id="fileone" type="file" class="file-loading">
                <input type="hidden" id="picurl" placeholder="面料缩略图" name="picurl" value="{$data.picurl ?? ''}">
            </div>
            
        </div>
        
    </div>


    <div class="panel-footer" style="padding-top: 50px;background: #fff;border-top:0px;">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-4">
                <input type="hidden" name="id" value="">
                
                <button type="submit" class="btn btn-primary" style="margin:0 auto;float: left;margin-left: 100px;" id="createMa">保存</button>
                <div id="maBox"></div>
                <button class="btn btn-default" style=" float: left;margin-left: 20px;" onclick="javascript:history.back(-1);">返回</button>
            </div>
        </div>
    </div>
    <!-- panel-footer -->
</form>
</div>
{/block} 
{block name="js"}
<script src="__PLUGIN__/Fileinput/js/fileinput.js"></script>
<script>
  $(function() {
    fileinputOne("fileone","picurl");
    $("[name='color']").find("[value='{$data.color ?? '-1'}']").attr("selected", true);
    $("[name='category']").find("[value='{$data.category ?? '-1'}']").attr("selected", true);
    $("[name='status'][value='{$data.status ?? '1'}']").attr("checked", true);
    $("[name='leibie'][value='{$data.leibie ?? '1'}']").attr("checked", true);
  });
    function fileinputOne(fileid,field){
      var widths = arguments[2] ? arguments[2] : 'auto';//设置默认的图片宽度
      var heights = arguments[3] ? arguments[3] : '160px';//设置默认的图片高度
      //单图上传
      var $input = $("#"+fileid);
      var $picurl = $("#"+field); 
      
      var $Preview =[];
      var $Config =[];
      if($picurl.val()!=''){
       $Preview =["<img class='kv-preview-data file-preview-image' style='width:"+widths+";height:"+heights+";' src='"+$picurl.val()+"'>"];
       $Config =[{key: 1}];
   }
   $input.fileinput({
      uploadUrl: "{:url('index/common/upload')}",
      deleteUrl: "{:url('index/common/updel')}",
      autoReplace: true,
      overwriteInitial: true,
      showUploadedThumbs: false,
      maxFileCount: 1,
      initialPreview: $Preview,
      initialPreviewConfig: $Config,
      layoutTemplates: {actionDelete: ''}, 
  }).on("filebatchselected", function(event, files) {
          $input.fileinput("upload");//选择后自动上传
      }).on('fileuploaded', function(event, data,previewId,index) {
           //alert(JSON.stringify(data));
           var dataObj=eval("("+data.response+")");
            if(dataObj['code']==0)
                  {  
               $picurl.val(dataObj['img']);
                  }
           else{
            swal("出错了", "上传失败,请刷新再试", "error");
               }
    }).on("filecleared", function(event, files) {
       $picurl.val('');
   });

}
</script>
{/block}